* Firm organization with multiple establishments
* Section III.B: Table IV, V; Appendix Tables B.4-B.11, B.14-B.17

clear all 
set matsize 4000
set more off

capture log close
log using log/08_facts-cs_MEorg_layer-firm.log, replace

use data/MEorg_2012_cs_layer-firm.dta, clear
count
desc

********************************************************************************
***	Establishment/HQ-level analyses	********************************************
********************************************************************************

gen ln_empl_bet = ln(empl_bet)

gen shr_mgmt_w_bet_glm = shr_mgmt_w_bet / 100
sum shr_mgmt_w_bet_glm
label variable shr_mgmt_w_bet_glm "Managerial share in wage sum, layer"

gen shr_bloss_w_bet_glm = shr_bloss_w_bet / 100
sum shr_bloss_w_bet_glm
label variable shr_bloss_w_bet_glm "Managerial share in wage sum, Blossfeld"

gen ln_prdt_wkr_2 = ln_prdt_workers * ln_prdt_workers
label variable ln_prdt_wkr_2 "Log \# non-m. employees of est., squared"

global FEestHQ		"d_est_08wz* d_ao_kreis*" 
global FEestHQ93	"d_est_93wz* d_ao_kreis*" 
global optSEest		"vce(cluster untid)"
global optSEHQ		"vce(robust)"
global optGLM		"link(logit) family(binomial) nolog"
global opttab		"b(%9.3f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress mtitles style(tex) label"

*	Text: share of establishments with more/same/fewer layers than headquarters
qui gen aux = count_mgmt_bet if hauptbet == 1
bys untid: egen count_mgmt_haupt = min(aux)
drop aux

tab2 count_mgmt_bet count_mgmt_haupt if hauptbet == 0

********************************************************************************
***	FIGURE II: Distance to HQ correlates positively with number of managerial layers of HQ and establishments

// Establishments
forvalues q = 10(10)90 {
	qui egen dist_dec`q' = pctile(ldistall) if hauptbet == 0, p(`q')
}
qui gen dec_dist = 100 if ldistall < . & hauptbet == 0
forval i = 90(-10)10 {
	qui replace dec_dist = `i' if ldistall <= dist_dec`i' & hauptbet == 0 & dist_dec`i' != .
}
tab dec_dist, m
drop dist_dec*

// Headquarters
forvalues q = 10(10)90 {
	qui egen dist_dechq`q' = pctile(max_log_dist) if hauptbet == 1 & max_log_dist != ., p(`q')
}
qui gen dec_disthq = 100 if max_log_dist < . & hauptbet == 1
forval i = 90(-10)10 {
	qui replace dec_disthq = `i' if max_log_dist <= dist_dechq`i' & hauptbet == 1 & dist_dechq`i' != .
}
tab dec_disthq if hauptbet == 1 & max_log_dist != ., m
drop dist_dechq*

*** FIGURE IIa: Establishments
tabstat count_mgmt_bet ldistall if hauptbet == 0, ///
	s(N mean semean p1 p5 p25 p50 p75 p95 p99) c(s) by(dec_dist)

*** FIGURE IIb: Headquarters
tabstat count_mgmt_bet ldistall if hauptbet == 1, ///
	s(N mean semean p1 p5 p25 p50 p75 p95 p99) c(s) by(dec_disthq)

********************************************************************************
***	FIGURE B.1: Distance to HQ and location and size of establishments, 2012 cross-section

gen rel_size = empl_bet / empl_unt

*** Figure B.1 b) Size
tabstat rel_size ldistall if hauptbet == 0, ///
	s(N mean semean p1 p5 p25 p50 p75 p95 p99) c(s) by(dec_dist)

*** Figure B.1 a) Location
preserve
keep if hauptbet == 0 & distance_all != . & distance_all > 0
count
kdensity distance_all, bwidth(25) generate(var_x var_y) nograph
	format var_x var_y %9.0g
	list var_x var_y if var_x~=., clean
restore

cap drop dec_dist
cap drop dec_disthq

********************************************************************************
***	Table V: Distance to HQ correlates positively with number of managerial layers of HQ and establishments

cap drop flg_est

eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers ldistall 	$FEestHQ if hauptbet == 0, $optSEest
eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm ldistall 					$FEestHQ if hauptbet == 0, $optGLM $optSEest
eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm ldistall 					$FEestHQ if hauptbet == 0, $optGLM $optSEest

eststo col4, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers max_log_dist	$FEestHQ if hauptbet == 1, $optSEHQ
eststo col5, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm max_log_dist 					$FEestHQ if hauptbet == 1, $optGLM $optSEHQ
eststo col6, title("Mg.share"):  qui glm shr_bloss_w_bet_glm max_log_dist  					$FEestHQ if hauptbet == 1, $optGLM $optSEHQ

esttab col1 col2 col3 col4 col5 col6, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers) 
esttab col1 col2 col3 col4 col5 col6, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers)
	
********************************************************************************
***	Table B.5: Distance quartiles

forvalues q = 25(25)75 {
	qui egen dist_qua`q' = pctile(ldistall) if hauptbet == 0, p(`q')
}
qui gen qua_dist = 100 if ldistall < . & hauptbet == 0
forval i = 75(-25)25 {
	qui replace qua_dist = `i' if ldistall <= dist_qua`i' & hauptbet == 0 & dist_qua`i' != .
}
tab qua_dist, gen(d_qua_dist) m
drop d_qua_dist1
drop dist_qua*
drop qua_dist

forvalues q = 25(25)75 {
	qui egen dist_quahq`q' = pctile(max_log_dist) if hauptbet == 1 & max_log_dist != ., p(`q')
}
qui gen qua_dist = 100 if max_log_dist < . & hauptbet == 1
forval i = 75(-25)25 {
	qui replace qua_dist = `i' if max_log_dist <= dist_quahq`i' & hauptbet == 1 & dist_quahq`i' != .
}
tab qua_dist if hauptbet == 1, gen(d_qua_dist_hq)
drop d_qua_dist_hq1
drop dist_quahq*
drop qua_dist

eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers d_qua_dist? 	$FEestHQ if hauptbet == 0 & ldistall != ., $optSEest
eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm d_qua_dist? 					$FEestHQ if hauptbet == 0 & ldistall != ., $optGLM $optSEest
eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm d_qua_dist? 					$FEestHQ if hauptbet == 0 & ldistall != ., $optGLM $optSEest

eststo col4, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers d_qua_dist_hq?	$FEestHQ if hauptbet == 1 & max_log_dist != ., $optSEHQ
eststo col5, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm d_qua_dist_hq? 					$FEestHQ if hauptbet == 1 & max_log_dist != ., $optGLM $optSEHQ
eststo col6, title("Mg.share"):  qui glm shr_bloss_w_bet_glm d_qua_dist_hq?					$FEestHQ if hauptbet == 1 & max_log_dist != ., $optGLM $optSEHQ

esttab col1 col2 col3 col4 col5 col6, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(d_qua_dist? d_qua_dist_hq? ln_prdt_workers) 
esttab col1 col2 col3 col4 col5 col6, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(d_qua_dist? d_qua_dist_hq? ln_prdt_workers) 

drop d_qua_dist? d_qua_dist_hq?

********************************************************************************
***	Table B.7: Non-linear size

eststo col2, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers ln_prdt_wkr_2 ldistall		$FEestHQ if hauptbet == 0, $optSEest
eststo col4, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers ln_prdt_wkr_2 max_log_dist	$FEestHQ if hauptbet == 1, $optSEHQ

esttab col2 col4, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers ln_prdt_wkr_2) 
esttab col2 col4, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers ln_prdt_wkr_2) 

********************************************************************************
***	Table B.10: Linear model 

eststo lin1, title("\# layers"): qui reghdfe count_mgmt_bet ln_prdt_workers ldistall 	if hauptbet == 0, $optSEest absorb(ao_kreis w08_3) 
eststo lin2, title("Mg.share"):  qui reghdfe shr_mgmt_w_bet ldistall 					if hauptbet == 0, $optSEest absorb(ao_kreis w08_3) 
eststo lin3, title("Mg.share"):  qui reghdfe shr_bloss_w_bet ldistall 					if hauptbet == 0, $optSEest absorb(ao_kreis w08_3) 

eststo lin4, title("\# layers"): qui reghdfe count_mgmt_bet ln_prdt_workers max_log_dist	if hauptbet == 1, $optSEHQ absorb(ao_kreis w08_3) 
eststo lin5, title("Mg.share"):  qui reghdfe shr_mgmt_w_bet max_log_dist 					if hauptbet == 1, $optSEHQ absorb(ao_kreis w08_3) 
eststo lin6, title("Mg.share"):  qui reghdfe shr_bloss_w_bet max_log_dist  					if hauptbet == 1, $optSEHQ absorb(ao_kreis w08_3) 

esttab lin1 lin2 lin3 lin4 lin5 lin6, ///
	$opttab se(%9.3f) r2 order(ldistall max_log_dist ln_prdt_workers) 
esttab lin1 lin2 lin3 lin4 lin5 lin6, ///
	$opttab p(%9.3f)  r2 order(ldistall max_log_dist ln_prdt_workers) 

********************************************************************************
***	Table B.11: Within-firm specification

eststo win1, title("\# layers"): qui reghdfe count_mgmt_bet ln_prdt_workers ldistall	if hauptbet == 0, $optSEest absorb(untid)
eststo win2, title("Mg.share"):  qui reghdfe shr_mgmt_w_bet ldistall 					if hauptbet == 0, $optSEest absorb(untid)
eststo win3, title("Mg.share"):  qui reghdfe shr_bloss_w_bet ldistall 					if hauptbet == 0, $optSEest absorb(untid)

eststo win4, title("\# layers"): qui reghdfe count_mgmt_bet ln_prdt_workers ldistall	if hauptbet == 0, $optSEest absorb(untid ao_kreis w08_3)
eststo win5, title("Mg.share"):  qui reghdfe shr_mgmt_w_bet ldistall 					if hauptbet == 0, $optSEest absorb(untid ao_kreis w08_3)
eststo win6, title("Mg.share"):  qui reghdfe shr_bloss_w_bet ldistall 					if hauptbet == 0, $optSEest absorb(untid ao_kreis w08_3)

esttab win1 win2 win3 win4 win5 win6, ///
	$opttab se(%9.3f) order(ldistall ln_prdt_workers) 
esttab win1 win2 win3 win4 win5 win6, ///
	$opttab p(%9.3f)  order(ldistall ln_prdt_workers)

********************************************************************************
***	Table B.15: By investment motive

***	All establishments in HQ sector vs. not: definition by wz
bys untid jahr: egen all_same_wz = mean(w08_3 == hq_wz)
qui replace all_same_wz = int(all_same_wz)
tab all_same_wz if flg_untjhr == 1
tab count_wz if all_same_wz == 1

// All same sector (horizontal)
preserve
keep if all_same_wz == 1 & hauptbet == 0
eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers ldistall 	$FEestHQ, $optSEest
eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm ldistall 					$FEestHQ, $optGLM $optSEest
eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm ldistall 					$FEestHQ, $optGLM $optSEest

esttab col1 col2 col3, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(ldistall ln_prdt_workers) 
esttab col1 col2 col3, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(ldistall ln_prdt_workers) 
restore

preserve
keep if all_same_wz == 1 & hauptbet == 1
eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers max_log_dist	$FEestHQ, $optSEHQ
eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm max_log_dist 					$FEestHQ, $optGLM $optSEHQ
eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm max_log_dist  					$FEestHQ, $optGLM $optSEHQ

esttab col1 col2 col3, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(max_log_dist ln_prdt_workers) 
esttab col1 col2 col3, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(max_log_dist ln_prdt_workers) 
restore

// At least one in different sector (vertical)
preserve
keep if all_same_wz == 0 & hauptbet == 0
eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers ldistall 	$FEestHQ, $optSEest
eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm ldistall 					$FEestHQ, $optGLM $optSEest
eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm ldistall 					$FEestHQ, $optGLM $optSEest

esttab col1 col2 col3, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(ldistall ln_prdt_workers) 
esttab col1 col2 col3, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(ldistall ln_prdt_workers) 
restore

preserve
keep if all_same_wz == 0 & hauptbet == 1
eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers max_log_dist	$FEestHQ, $optSEHQ
eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm max_log_dist 					$FEestHQ, $optGLM $optSEHQ
eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm max_log_dist  					$FEestHQ, $optGLM $optSEHQ

esttab col1 col2 col3, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(max_log_dist ln_prdt_workers) 
esttab col1 col2 col3, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(max_log_dist ln_prdt_workers) 
restore

********************************************************************************
***	Table B.17: By legal form

//	Labels legal: 1 "Einzelunternehmen" 2 "GmbH & coKG" 3 "GmbH" 4 "AG"

forvalues l = 2/4 {
	display "------------------------------------"
	display "-------- Legal form: `l' -----------"

	
	tab count_mgmt_bet if hauptbet == 0 & legal_form == `l', m 
	eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers ldistall 	$FEestHQ if hauptbet == 0 & legal_form == `l', $optSEest
	eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm ldistall 					$FEestHQ if hauptbet == 0 & legal_form == `l', $optGLM $optSEest
	eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm ldistall 					$FEestHQ if hauptbet == 0 & legal_form == `l', $optGLM $optSEest
	
	tab count_mgmt_bet if hauptbet == 1 & legal_form == `l', m 
	eststo col4, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers max_log_dist	$FEestHQ if hauptbet == 1 & legal_form == `l', $optSEHQ
	eststo col5, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm max_log_dist 					$FEestHQ if hauptbet == 1 & legal_form == `l', $optGLM $optSEHQ
	eststo col6, title("Mg.share"):  qui glm shr_bloss_w_bet_glm max_log_dist  					$FEestHQ if hauptbet == 1 & legal_form == `l', $optGLM $optSEHQ
	
	esttab col1 col2 col3 col4 col5 col6, ///
		$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers) 
	esttab col1 col2 col3 col4 col5 col6, ///
		$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers) 

	}


********************************************************************************
***	Unreported: Dropping retail
*** We observe very low wages in establishments in layer 3 in the cross-section. 
*** This likely stems from the retail sector. Our results are robust to dropping retail.

cap drop w08_2
gen w08_2 = int(w08_3 / 10)

eststo col1, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers ldistall 	$FEestHQ if hauptbet == 0 & w08_2 != 47, $optSEest
eststo col2, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm ldistall  					$FEestHQ if hauptbet == 0 & w08_2 != 47, $optGLM $optSEest
eststo col3, title("Mg.share"):  qui glm shr_bloss_w_bet_glm ldistall  					$FEestHQ if hauptbet == 0 & w08_2 != 47, $optGLM $optSEest

eststo col4, title("\# layers"): qui poisson count_mgmt_bet ln_prdt_workers max_log_dist	$FEestHQ if hauptbet == 1 & w08_2 != 47, $optSEHQ
eststo col5, title("Mg.share"):  qui glm shr_mgmt_w_bet_glm max_log_dist  					$FEestHQ if hauptbet == 1 & w08_2 != 47, $optGLM $optSEHQ
eststo col6, title("Mg.share"):  qui glm shr_bloss_w_bet_glm max_log_dist  					$FEestHQ if hauptbet == 1 & w08_2 != 47, $optGLM $optSEHQ

esttab col1 col2 col3 col4 col5 col6, ///
	$opttab se(%9.3f) indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers) 
esttab col1 col2 col3 col4 col5 col6, ///
	$opttab p(%9.3f)  indicate($FEestHQ, labels(Y N)) order(ldistall max_log_dist ln_prdt_workers) 

********************************************************************************
***	Firm-level analyses	********************************************************
********************************************************************************

estimates clear

keep if flg_untjhr == 1
drop flg_untjhr
drop d_ao_kreis* d_est_08wz* d_est_93wz*

drop betnr w93_3_gen w08_3 ao_kreis hauptbet empl_bet distance* ldist* ///
	count_mgmt_bet shr_mgmt_bet prdt_wkrs_bet ln_prdt_workers shr_mgmt_w_bet shr_mgmt_bet_bloss ///
	shr_bloss_w_bet*
desc

gen shr_mgmt_w_unt_glm = shr_mgmt_w_unt / 100
sum shr_mgmt_w_unt_glm
label variable shr_mgmt_w_unt_glm "Managerial share in wage sum, layer"

gen shr_bloss_w_unt_glm = shr_bloss_w_unt / 100
sum shr_bloss_w_unt_glm
label variable shr_bloss_w_unt_glm "Managerial share in wage sum, Blossfeld"

gen ln_prdt_wkr_unt_2 = ln_prdt_wkr_unt * ln_prdt_wkr_unt
label variable ln_prdt_wkr_unt_2 "Log \# non-m. employees of firm, squared"
gen ln_sales_2 = ln_sales * ln_sales
label variable ln_sales_2 "Log sales of firm, squared"

global FEunt	"d_08wz* d_hq_kreis* d_legal*" // d_08wz bezieht sich auf HQ Sektor
global FEunt93	"d_93wz* d_hq_kreis* d_legal*" // d_93wz bezieht sich auf HQ Sektor
global optSEunt	"vce(robust)"

********************************************************************************
***	FIGURE I: Distance to HQ correlates positively with number of managerial layers of ME firms

forvalues q = 10(10)90 {
	qui egen dist_dechq`q' = pctile(max_log_dist), p(`q')
}
qui gen dec_disthq = 100 if max_log_dist < .
forval i = 90(-10)10 {
	qui replace dec_disthq = `i' if max_log_dist <= dist_dechq`i' & dist_dechq`i' != .
}
tab dec_disthq, m
drop dist_dechq*

tabstat count_mgmt_unt max_log_dist, s(N mean p1 p50 p99) c(s) by(dec_disthq)
drop dec_disthq

********************************************************************************
***	TABLE IV: Distance to HQ correlates positively with number of managerial layers of ME firms

cap drop flg_untid

eststo col1, title("\# layers"): qui poisson count_mgmt_unt ln_sales max_log_dist	$FEunt, $optSEunt
eststo col2, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_area  		$FEunt, $optSEunt
eststo col3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt max_log_dist	$FEunt, $optSEunt
eststo col4, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_area			$FEunt, $optSEunt

eststo col5, title("Mg.share"): qui glm shr_mgmt_w_unt_glm max_log_dist 	$FEunt, $optGLM $optSEunt
eststo col6, title("Mg.share"): qui glm shr_mgmt_w_unt_glm ln_area  		$FEunt, $optGLM $optSEunt
eststo col7, title("Mg.share"): qui glm shr_bloss_w_unt_glm max_log_dist	$FEunt, $optGLM $optSEunt
eststo col8, title("Mg.share"): qui glm shr_bloss_w_unt_glm ln_area			$FEunt, $optGLM $optSEunt

esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab se(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab p(%9.3f)  indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)

********************************************************************************
***	Table B.4: Distance quartiles

preserve
keep if max_dist > 0

forvalues q = 25(25)75 {
	qui egen dist_quahq`q' = pctile(max_dist), p(`q')
}
qui gen qua_dist = 100 if max_dist < .
forval i = 75(-25)25 {
	qui replace qua_dist = `i' if max_dist <= dist_quahq`i' & dist_quahq`i' != .
}
tab qua_dist, gen(d_qua_dist_hq)
drop d_qua_dist_hq1
drop dist_quahq*
drop qua_dist

eststo qua1, title("\# layers"): qui poisson count_mgmt_unt ln_sales d_qua_dist_hq?			$FEunt, $optSEunt
eststo qua3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt d_qua_dist_hq?	$FEunt, $optSEunt

eststo qua5, title("Mg.share"):  qui glm shr_mgmt_w_unt_glm d_qua_dist_hq? 	$FEunt, $optGLM $optSEunt
eststo qua7, title("Mg.share"):  qui glm shr_bloss_w_unt_glm d_qua_dist_hq?	$FEunt, $optGLM $optSEunt

esttab qua1 qua3 qua5 qua7, ///
	$opttab se(%9.3f) indicate($FEunt, labels(Y N)) order(d_qua_dist_hq2 d_qua_dist_hq3 d_qua_dist_hq4 ln_sales ln_prdt_wkr_unt)
esttab qua1 qua3 qua5 qua7, ///
	$opttab p(%9.3f)  indicate($FEunt, labels(Y N)) order(d_qua_dist_hq2 d_qua_dist_hq3 d_qua_dist_hq4 ln_sales ln_prdt_wkr_unt)

drop d_qua_dist_hq?
restore

********************************************************************************
***	Table B.6: Non-linear size 

eststo nol1, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_sales_2	max_log_dist	$FEunt, $optSEunt
eststo nol2, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_sales_2	ln_area  		$FEunt, $optSEunt
eststo nol3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_prdt_wkr_unt_2 max_log_dist	$FEunt, $optSEunt
eststo nol4, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_prdt_wkr_unt_2 ln_area		$FEunt, $optSEunt

esttab nol1 nol2 nol3 nol4, ///
	$opttab se(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_sales_2 ln_prdt_wkr_unt ln_prdt_wkr_unt_2)
esttab nol1 nol2 nol3 nol4, ///
	$opttab  p(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_sales_2 ln_prdt_wkr_unt ln_prdt_wkr_unt_2)

********************************************************************************
***	Table B.8: number of establishments

gen count_sub = count_est-1

eststo rob1, title("\# layers"): qui poisson count_mgmt_unt ln_sales max_log_dist count_sub	$FEunt, $optSEunt
eststo rob2, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_area count_sub		$FEunt, $optSEunt
eststo rob3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt max_log_dist count_sub	$FEunt, $optSEunt
eststo rob4, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_area count_sub		$FEunt, $optSEunt

eststo rob5, title("Mg.share"): qui glm shr_mgmt_w_unt_glm max_log_dist count_sub	$FEunt, $optGLM $optSEunt
eststo rob6, title("Mg.share"): qui glm shr_mgmt_w_unt_glm ln_area count_sub		$FEunt, $optGLM $optSEunt
eststo rob7, title("Mg.share"): qui glm shr_bloss_w_unt_glm max_log_dist count_sub	$FEunt, $optGLM $optSEunt
eststo rob8, title("Mg.share"): qui glm shr_bloss_w_unt_glm ln_area count_sub		$FEunt, $optGLM $optSEunt

esttab rob1 rob2 rob3 rob4 rob5 rob6 rob7 rob8, ///
	$opttab se(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt count_sub)
esttab rob1 rob2 rob3 rob4 rob5 rob6 rob7 rob8, ///
	$opttab  p(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt count_sub)

********************************************************************************
***	Table B.9: Linear model 

eststo lin1, title("\# layers"): qui reghdfe count_mgmt_unt ln_sales max_log_dist,	$optSEunt absorb(hq_kreis hq_wz legal_form)
eststo lin2, title("\# layers"): qui reghdfe count_mgmt_unt ln_sales ln_area,		$optSEunt absorb(hq_kreis hq_wz legal_form)
eststo lin3, title("\# layers"): qui reghdfe count_mgmt_unt ln_prdt_wkr_unt max_log_dist,	$optSEunt absorb(hq_kreis hq_wz legal_form) 
eststo lin4, title("\# layers"): qui reghdfe count_mgmt_unt ln_prdt_wkr_unt ln_area,		$optSEunt absorb(hq_kreis hq_wz legal_form)

eststo lin5, title("Mg.share"):  qui reghdfe shr_mgmt_w_unt max_log_dist,	$optSEunt absorb(hq_kreis hq_wz legal_form)
eststo lin6, title("Mg.share"):  qui reghdfe shr_mgmt_w_unt ln_area,		$optSEunt absorb(hq_kreis hq_wz legal_form)
eststo lin7, title("Mg.share"):  qui reghdfe shr_bloss_w_unt max_log_dist,	$optSEunt absorb(hq_kreis hq_wz legal_form)
eststo lin8, title("Mg.share"):  qui reghdfe shr_bloss_w_unt ln_area,		$optSEunt absorb(hq_kreis hq_wz legal_form)

esttab lin1 lin2 lin3 lin4 lin5 lin6 lin7 lin8, ///
	$opttab se(%9.3f) r2 order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
esttab lin1 lin2 lin3 lin4 lin5 lin6 lin7 lin8, ///
	$opttab  p(%9.3f) r2 order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)

********************************************************************************
***	Table B.14: by investment motive 

***	All establishments in HQ sector vs. not: definition by wz
preserve
keep if all_same_wz == 1

eststo col1, title("\# layers"): qui poisson count_mgmt_unt ln_sales max_log_dist	$FEunt, $optSEunt
eststo col2, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_area  		$FEunt, $optSEunt
eststo col3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt max_log_dist	$FEunt, $optSEunt
eststo col4, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_area			$FEunt, $optSEunt

eststo col5, title("Mg.share"): qui glm shr_mgmt_w_unt_glm max_log_dist 	$FEunt, $optGLM $optSEunt
eststo col6, title("Mg.share"): qui glm shr_mgmt_w_unt_glm ln_area  		$FEunt, $optGLM $optSEunt
eststo col7, title("Mg.share"): qui glm shr_bloss_w_unt_glm max_log_dist	$FEunt, $optGLM $optSEunt
eststo col8, title("Mg.share"): qui glm shr_bloss_w_unt_glm ln_area			$FEunt, $optGLM $optSEunt

esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab se(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab p(%9.3f)  indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
restore

preserve
keep if all_same_wz == 0

eststo col1, title("\# layers"): qui poisson count_mgmt_unt ln_sales max_log_dist	$FEunt, $optSEunt
eststo col2, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_area  		$FEunt, $optSEunt
eststo col3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt max_log_dist	$FEunt, $optSEunt
eststo col4, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_area			$FEunt, $optSEunt

eststo col5, title("Mg.share"): qui glm shr_mgmt_w_unt_glm max_log_dist 	$FEunt, $optGLM $optSEunt
eststo col6, title("Mg.share"): qui glm shr_mgmt_w_unt_glm ln_area  		$FEunt, $optGLM $optSEunt
eststo col7, title("Mg.share"): qui glm shr_bloss_w_unt_glm max_log_dist	$FEunt, $optGLM $optSEunt
eststo col8, title("Mg.share"): qui glm shr_bloss_w_unt_glm ln_area			$FEunt, $optGLM $optSEunt

esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab se(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab p(%9.3f)  indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
restore


********************************************************************************
***	Table B.16: By legal form

//	label define legal 1 "Einzelunternehmen" 2 "GmbH & coKG" 3 "GmbH" 4 "AG"

forvalues l = 2/4 {
	display "------------------------------------"
	display "-------- Legal form: `l' -----------"

	tab count_mgmt_unt if legal_form == `l', m 
	
	eststo col1, title("\# layers"): qui poisson count_mgmt_unt ln_sales max_log_dist	d_08wz* d_hq_kreis* if legal_form == `l', $optSEunt
	eststo col2, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_area  		d_08wz* d_hq_kreis* if legal_form == `l', $optSEunt
	eststo col3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt max_log_dist	d_08wz* d_hq_kreis* if legal_form == `l', $optSEunt
	eststo col4, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_area			d_08wz* d_hq_kreis* if legal_form == `l', $optSEunt

	eststo col5, title("Mg.share"):  qui glm shr_mgmt_w_unt_glm max_log_dist 	d_08wz* d_hq_kreis* if legal_form == `l', $optGLM $optSEunt
	eststo col6, title("Mg.share"):  qui glm shr_mgmt_w_unt_glm ln_area  		d_08wz* d_hq_kreis* if legal_form == `l', $optGLM $optSEunt
	eststo col7, title("Mg.share"):  qui glm shr_bloss_w_unt_glm max_log_dist 	d_08wz* d_hq_kreis* if legal_form == `l', $optGLM $optSEunt
	eststo col8, title("Mg.share"):  qui glm shr_bloss_w_unt_glm ln_area		d_08wz* d_hq_kreis* if legal_form == `l', $optGLM $optSEunt
	
	esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
		$opttab se(%9.3f) indicate(d_08wz* d_hq_kreis*, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
	esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
		$opttab  p(%9.3f) indicate(d_08wz* d_hq_kreis*, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
}

********************************************************************************
***	Robustness: No retail 

preserve
cap drop w08_2
gen w08_2 = int(hq_wz / 10)
keep if w08_2 != 47

eststo col1, title("\# layers"): qui poisson count_mgmt_unt ln_sales max_log_dist	$FEunt, $optSEunt
eststo col2, title("\# layers"): qui poisson count_mgmt_unt ln_sales ln_area  		$FEunt, $optSEunt
eststo col3, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt max_log_dist	$FEunt, $optSEunt
eststo col4, title("\# layers"): qui poisson count_mgmt_unt ln_prdt_wkr_unt ln_area			$FEunt, $optSEunt

eststo col5, title("Mg.share"): qui glm shr_mgmt_w_unt_glm max_log_dist 	$FEunt, $optGLM $optSEunt
eststo col6, title("Mg.share"): qui glm shr_mgmt_w_unt_glm ln_area  		$FEunt, $optGLM $optSEunt
eststo col7, title("Mg.share"): qui glm shr_bloss_w_unt_glm max_log_dist	$FEunt, $optGLM $optSEunt
eststo col8, title("Mg.share"): qui glm shr_bloss_w_unt_glm ln_area			$FEunt, $optGLM $optSEunt

esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab se(%9.3f) indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
esttab col1 col2 col3 col4 col5 col6 col7 col8, ///
	$opttab p(%9.3f)  indicate($FEunt, labels(Y N)) order(max_log_dist ln_area ln_sales ln_prdt_wkr_unt)
restore

log close
